package main

import (
	"fmt"
)

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func maxAdjacentDistance(nums []int) int {
    n := len(nums)
	ans := 0
	for i := 0; i < n; i++ {
		left := (i - 1 + n) % n
		right := (i + 1) % n
		b := max(abs(nums[i] - nums[left]), abs(nums[i] - nums[right]))
		ans = max(ans, b)
	}
	return ans
}


func main() {
	nums := []int{1, 2, 4}
	fmt.Println(maxAdjacentDistance(nums))
}